import { _decorator, Component, Node } from 'cc';
import { app } from './App';
import { eventMgr } from '../../core/module/event/EventMgr';
import { audioMgr } from '../../core/module/audio/AudioMgr';
import { resMgr } from '../../core/module/res/ResMgr';
import { sceneMgr } from '../../core/module/scene/SceneMgr';
import { LoginScene } from '../scene/LoginScene';
import { LobbyScene } from '../scene/LobbyScene';
import { GameScene } from '../scene/GameScene';
import { proxyMgr } from '../../core/module/proxy/ProxyMgr';
import { ModelMgr } from '../manager/ModelMgr';
import { ToastMgr } from '../manager/ToastMgr';
import { configMgr } from '../../core/module/config/ConfigMgr';
import { uiMgr } from '../../core/module/ui/UIMgr';
import { LayerEnum, SceneEnum } from '../share/Enum';
import { hotMgr } from '../../core/module/hot/HotMgr';
import { NetMgr } from '../manager/NetMgr';
import { httpMgr } from '../../core/module/http/HttpMgr';

const { ccclass, property } = _decorator;

@ccclass('Boost')
export class Boost extends Component {
    @property(Node)
    baseLayer: Node = null;
    @property(Node)
    gameLayer: Node = null;
    @property(Node)
    poupLayer: Node = null;
    @property(Node)
    floatLayer: Node = null;
    @property(Node)
    systemLayer: Node = null;
    start() {
        this.initApp()
        this.registerScene()
        this.registerLayer()
        app.scene.startScene(SceneEnum.Login)
    }

    initApp() {
        app.proxy = proxyMgr;
        app.ui = uiMgr;
        app.event = eventMgr;
        app.sound = audioMgr;
        app.res = resMgr;
        app.hot = hotMgr;
        app.scene = sceneMgr;
        app.config = configMgr;
        app.http = httpMgr;
        app.net = new NetMgr();
        app.model = new ModelMgr();
        app.toast = new ToastMgr();
    }

    registerScene() {
        app.scene.registerScene(SceneEnum.Login, new LoginScene())
        app.scene.registerScene(SceneEnum.Lobby, new LobbyScene())
        app.scene.registerScene(SceneEnum.Game, new GameScene())
    }
    registerLayer() {
        app.ui.init(new Map([
            [LayerEnum.base, { root: this.baseLayer, water: 0 }],
            [LayerEnum.float, { root: this.floatLayer, water: 0 }],
            [LayerEnum.game, { root: this.gameLayer, water: 0 }],
            [LayerEnum.poup, { root: this.poupLayer, water: 0 }],
            [LayerEnum.system, { root: this.systemLayer, water: 0 }],
        ]))
    }
}


